<template>
  <div class="admin-layout">
    <!-- 左侧菜单 -->
    <div class="sidebar">
      <div class="logo">
        <h2>鞋业在线后台管理</h2>
      </div>
      
      <nav class="menu">
        <ul>
          <li>
            <router-link to="/admin/dashboard" class="menu-item">
              <span class="menu-icon">🏠</span>
              主页
            </router-link>
          </li>
          
          <li class="menu-group">
            <div class="menu-title">商品管理</div>
            <ul class="submenu">
              <li>
                <router-link to="/admin/products" class="menu-item">
                  <span class="menu-icon">📦</span>
                  产品列表
                </router-link>
              </li>
              <li>
                <router-link to="/admin/brands" class="menu-item">
                  <span class="menu-icon">🏷️</span>
                  品牌列表
                </router-link>
              </li>
              <li>
                <router-link to="/admin/categories" class="menu-item">
                  <span class="menu-icon">📂</span>
                  类型列表
                </router-link>
              </li>
              <li>
                <router-link to="/admin/colors" class="menu-item">
                  <span class="menu-icon">🎨</span>
                  颜色列表
                </router-link>
              </li>
              <li>
                <router-link to="/admin/sizes" class="menu-item">
                  <span class="menu-icon">📏</span>
                  尺寸列表
                </router-link>
              </li>
            </ul>
          </li>
          
          <li class="menu-group">
            <div class="menu-title">订单管理</div>
            <ul class="submenu">
              <li>
                <router-link to="/admin/orders/pending" class="menu-item">
                  <span class="menu-icon">⏳</span>
                  待发货订单
                </router-link>
              </li>
              <li>
                <router-link to="/admin/orders/shipping" class="menu-item">
                  <span class="menu-icon">🚚</span>
                  运输中订单
                </router-link>
              </li>
              <li>
                <router-link to="/admin/orders/completed" class="menu-item">
                  <span class="menu-icon">✅</span>
                  交易成功的订单
                </router-link>
              </li>
              <li>
                <router-link to="/admin/orders/return-request" class="menu-item">
                  <span class="menu-icon">🔄</span>
                  申请退货订单
                </router-link>
              </li>
              <li>
                <router-link to="/admin/orders/returned" class="menu-item">
                  <span class="menu-icon">📦</span>
                  已退货订单
                </router-link>
              </li>
              <li>
                <router-link to="/admin/orders/canceled" class="menu-item">
                  <span class="menu-icon">❌</span>
                  已取消订单
                </router-link>
              </li>
            </ul>
          </li>
          
          <li class="menu-group">
            <div class="menu-title">用户管理</div>
            <ul class="submenu">
              <li>
                <router-link to="/admin/users" class="menu-item">
                  <span class="menu-icon">👥</span>
                  用户列表
                </router-link>
              </li>
            </ul>
          </li>
          
          <li class="menu-group">
            <div class="menu-title">查看报表</div>
            <ul class="submenu">
              <li>
                <router-link to="/admin/reports/performance" class="menu-item">
                  <span class="menu-icon">📊</span>
                  业绩报表
                </router-link>
              </li>
              <li>
                <router-link to="/admin/reports/marketing" class="menu-item">
                  <span class="menu-icon">📈</span>
                  营销报表
                </router-link>
              </li>
              <li>
                <router-link to="/admin/reports/traffic" class="menu-item">
                  <span class="menu-icon">🌐</span>
                  流量报表
                </router-link>
              </li>
            </ul>
          </li>
          
          <li class="menu-group">
            <div class="menu-title">企业管理</div>
            <ul class="submenu">
              <li>
                <router-link to="/admin/company/links" class="menu-item">
                  <span class="menu-icon">🔗</span>
                  合作链接管理
                </router-link>
              </li>
              <li>
                <router-link to="/admin/company/ads" class="menu-item">
                  <span class="menu-icon">📢</span>
                  广告管理
                </router-link>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
    </div>
    
    <!-- 右侧内容区域 -->
    <div class="main-content">
      <div class="header">
        <div class="user-info">
          <span>欢迎，{{ username }}</span>
          <button @click="logout" class="logout-btn">退出登录</button>
        </div>
      </div>
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
export default {
  name: 'AdminLayout',
  data() {
    return {
      username: localStorage.getItem('username') || '管理员'
    }
  },
  methods: {
    logout() {
      // 清除登录状态
      localStorage.removeItem('isLoggedIn')
      localStorage.removeItem('username')
      
      // 跳转到登录页面
      this.$router.push('/login')
    }
  }
}
</script>

<style scoped>
.admin-layout {
  display: flex;
  height: 100vh;
  background-color: #f5f5f5;
}

.sidebar {
  width: 280px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  overflow-y: auto;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.logo {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: white;
}

.menu {
  padding: 20px 0;
}

.menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.menu-group {
  margin-bottom: 20px;
}

.menu-title {
  padding: 10px 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 1px;
}

.submenu {
  margin-top: 5px;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.menu-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  border-left-color: #fff;
}

.menu-item.router-link-active {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border-left-color: #fff;
}

.menu-icon {
  margin-right: 12px;
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.main-content {
  flex: 1;
  overflow-y: auto;
}

.header {
  background: white;
  padding: 15px 20px;
  border-bottom: 1px solid #e1e5e9;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-info span {
  color: #333;
  font-size: 14px;
}

.logout-btn {
  background: #dc3545;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s ease;
}

.logout-btn:hover {
  background: #c82333;
}

.main-content > :last-child {
  padding: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .sidebar {
    width: 250px;
  }
  
  .logo h2 {
    font-size: 16px;
  }
}
</style> 